

*-------------------------------------------------------------------------------
* collect data
*-------------------------------------------------------------------------------

* traffic stop data
use "data/outputs/TSSS_beat.dta", clear
keep if agencyname == "CHICAGO POLICE"

* collapse
collapse (sum) count citation black white black_citation white_citation ///
		 reason_*, by(month)

* citation rate by race
gen whitecitationrate = white_citation / white
gen blackcitationrate = black_citation / black

* equipment stops by race
gen whiteequiprate = reason_equip_white / white
gen blackequiprate = reason_equip_black / black

* shaded region
gen treatment = 1 if (month >= tm(2015m8) & month <= tm(2016m1))


*-------------------------------------------------------------------------------
* graphs
*-------------------------------------------------------------------------------

* citation rates
#delimit;
twoway (area treatment month if month >= tm(2012m1) & month <= tm(2020m2), 
lcolor(gs15%100) fcolor(gs15%100))
(connected whitecitationrate month if month >= tm(2012m1) & month <= tm(2020m3),
lcolor(black) mcolor(black) msize(small) msymbol(square))
(connected blackcitationrate month if month >= tm(2012m1) & month <= tm(2020m3),
lcolor(red) mcolor(red) msize(small)),
graphregion(fcolor(white) lcolor(white) margin(zero))
plotregion(fcolor(white) lstyle(none) lcolor(white) ilstyle(none))
xsize(7) ysize(5)
title("", 
	  color(black) placement(west) justification(left) size(medlarge)) 
ytitle("Proportion of traffic stops producing a citation", size(medlarge))
yscale(lcolor(none))
ylabel(0(.2)1, labsize(large) glcolor(white) angle(horizontal) axis(1))
xtitle("", size(medsmall)) 
xscale(lcolor(none) range(636 722))
xlabel(624(12)720, labsize(medlarge) format(%tmCY)) 
legend(order(2 "White Drivers" 3 "Black Drivers")
ring(0) pos(2) rows(2) symxsize(*.25));
graph export "figures/Figure5a.pdf", replace;

* proportion of stops for equipment
#delimit;
twoway (area treatment month if month >= tm(2012m1) & month <= tm(2020m2), 
lcolor(gs15%100) fcolor(gs15%100))
(connected whiteequiprate month if month >= tm(2012m1) & month <= tm(2020m3),
lcolor(black) mcolor(black) msize(small) msymbol(square))
(connected blackequiprate month if month >= tm(2012m1) & month <= tm(2020m3),
lcolor(red) mcolor(red) msize(small)),
graphregion(fcolor(white) lcolor(white) margin(zero))
plotregion(fcolor(white) lstyle(none) lcolor(white) ilstyle(none))
xsize(7) ysize(5)
title("", 
	  color(black) placement(west) justification(left) size(medlarge)) 
ytitle("Proportion of traffic stops for equipment", size(medlarge))
yscale(lcolor(none))
ylabel(0(.2)1, labsize(large) glcolor(white) angle(horizontal) axis(1))
xtitle("", size(medsmall)) 
xscale(lcolor(none) range(636 722))
xlabel(624(12)720, labsize(medlarge) format(%tmCY)) 
legend(order(2 "White Drivers" 3 "Black Drivers")
ring(0) pos(2) rows(2) symxsize(*.25));
graph export "figures/Figure5b.pdf", replace;


* End
